package handler

import (
	"api-getway/global"
	doctor "api-getway/internal/pb/doctor"
	"api-getway/internal/resp"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
)

func RoomList(c *gin.Context) {
	name := c.Query("name")
	list, err := global.DoctorClient.RoomList(c, &doctor.RoomListRequest{
		Name: name,
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error:": "错误" + err.Error()})
		return
	}
	c.JSON(http.StatusOK, resp.Res{
		Code: 200,
		Msg:  "成功",
		Data: map[string]interface{}{"data": list},
	})
}
func HospitalList(c *gin.Context) {
	page, _ := strconv.Atoi(c.Query("page"))
	pageSize, _ := strconv.Atoi(c.Query("page_size"))
	list, err := global.DoctorClient.HospitalList(c, &doctor.HospitalRequest{
		Page:     int32(page),
		PageSize: int32(pageSize),
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error:": "错误" + err.Error()})
		return
	}
	c.JSON(http.StatusOK, resp.Res{
		Code: 200,
		Msg:  "成功",
		Data: map[string]interface{}{"data": list},
	})
}
